#ifndef __SPRITE__H__
#define __SPRITE__H__

#include <stdint.h>
#ifdef OPENGL
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
#endif

typedef struct _texture_t{
#ifdef OPENGL
    GLfloat texx, texy, texx2, texy2;
    GLuint texture;
    short texw, texh;
#endif/*OPENGL*/
} texture_t;

typedef struct _texture_location_t{
    short x, y, w, h;
} texture_location_t;

typedef struct _sprite_t{
    texture_location_t loc;
    texture_t tex;
} sprite_t;

typedef struct _sprite_list_node_t{
    sprite_t *spr;
    struct _sprite_list_node_t *prev, *next;
} sprite_list_node_t;

typedef struct _sprite_file_data_t{
    const char *pngfile;
    uint16_t x, y, w, h;
} sprite_file_data_t;

sprite_t* crt_spr();
sprite_t* create_sub_spr(const sprite_t *spr, const int x, const int y, 
        const int width, const int height);
int change_texture_location(sprite_t *spr, const int x, const int y,
        const int width, const int height);
void free_spr(sprite_t **spr);
int load_png(const char *filename, sprite_t *spr);
int bind_sprite(sprite_t *spr, char *data);
void render_gui();
void init_gui();

sprite_list_node_t* create_sprite_list();
void free_sprite_list(sprite_list_node_t **list);
sprite_list_node_t* sprite_list_add(sprite_list_node_t *head, sprite_t *spr);
sprite_list_node_t* sprite_list_remove(sprite_list_node_t *spr_node);

//RETURN TO THIS LATER
int load_sprite(uint16_t id, sprite_file_data_t, sprite_t *spr);
sprite_t* sprite_is_loaded(uint16_t id);

#endif
